import { defineStore } from 'pinia'
import { http } from '@/utils/request'
import type { Member } from '@/types'
const member = defineStore('member', {
  state: () => ({
    token: localStorage.getItem('token')
  }),
  getters: {
    isLogin(): boolean {
      return this.token ? true : false
    }
  },
  actions: {
    async login(form: Member) {
      const res = await http<string>('post', '/sys/login', form)
      const token = res.data.data
      this.token = token
      localStorage.setItem('token', token)
    }
  }
})
export default member
